package com.lvyq.myplayer.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.lvyq.myplayer.R
import com.lvyq.myplayer.model.yudan.YueDanItemBeans
import com.squareup.picasso.Picasso
import org.jetbrains.anko.find

/**
 * 文件描述：YueDanItemView
 * 作者：lvyq
 * 创建时间：2025-02-24
 * 修改时间：2025-02-24
 */
class YueDanItemView: RelativeLayout {

     lateinit var title : TextView
     lateinit var singer :TextView
    lateinit var bg :ImageView
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )
    init {
        View.inflate(context, R.layout.item_yuedan,this)
        title=find<TextView>(R.id.title)
        singer = find<TextView>(R.id.singer)
         bg = find<ImageView>(R.id.bg)
    }

    //赋值
    fun setData(data: YueDanItemBeans) {
        title.setText(data.title)
        singer.setText(data.singer)
        bg = find<ImageView>(R.id.bg)
        //背景图
        Picasso.with(context).load(data.img).into(bg)
    }

}